package com.jy.wms;

import com.joyi.gate.filter.SSOFilter;
import com.joyi.gate.filter.UrlFilter;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import javax.servlet.Filter;

/*

@EnableFeignClients
@EnableDiscoveryClient
*/
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
@EnableSwagger2
@EnableCaching
/*@ComponentScan("org.jeecgframework.poi.excel.view")*/

@ComponentScan(basePackages = {"com.jy.wms"})
@MapperScan("com.jy.wms.dao")
public class WmsApplication {
    @Bean
    public Filter indexFilter() {
        return new SSOFilter();
    }

    @Bean
    public FilterRegistrationBean indexFilterRegistration() {
        FilterRegistrationBean registration = new FilterRegistrationBean(indexFilter());
        registration.addUrlPatterns("*");
        return registration;
    }

    @Bean
    public Filter testFilter() {
        return new UrlFilter();
    }

    @Bean
    public FilterRegistrationBean indexFilterUrlFunc() {
        FilterRegistrationBean registration = new FilterRegistrationBean(testFilter());
        registration.addUrlPatterns("*");
        return registration;
    }

    public static void main(String[] args) {
        SpringApplication.run(WmsApplication.class, args);
    }
}
